package com.example.path;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2024-02-28
 * Time: 21:34
 *
 * 路径参数演示
 */

@Controller
@RequestMapping("/path")
@ResponseBody
public class PathController {

    /**
     * 动态路径设计
     * path/{账号}/{密码}
     * 但是必须在方法上加上 @PathVariable 注解，否则会被当成路径
     */
    @GetMapping("/{account}/{password}")
    public String login(@PathVariable("account") String account, @PathVariable("password") String password) {
        System.out.println("账号：" + account + "，密码：" + password);
        return "登录成功";
    }
}
